import { Component } from '@angular/core';

import { NavController, NavParams } from 'ionic-angular';

import { CategoryListPage } from '../category-list/category-list';
import {parser} from '../../engine/findengine'


@Component({
  selector: 'page-category',
  templateUrl: 'category.html'
})
export class CategoryPage {
  selectedItem: any;
  icons: string[];
  items: Array<{title: string, note: string, icon: string, url: string}>;

  constructor(public navCtrl: NavController, public navParams: NavParams) {
    // If we navigated to this page, we will have an item available as a nav param
    this.selectedItem = navParams.get('item');

    this.icons = ['flask', 'wifi', 'beer', 'football', 'basketball','aperture','appstore'];
    let tags = parser.getTags();

    this.items = [];
    for(let i = 0; i < tags.length; i++) {
      this.items.push({
        title: tags[i].title,
        note: 'This is item #' + i,
        icon: this.icons[Math.floor(Math.random() * this.icons.length)],
        url: tags[i].url
      });
    }
  }

  itemTapped(event, item) {
    this.navCtrl.push(CategoryListPage, {
      item: item
    });
  }
}
